/*
 * This file is part of ksPlatform
 * 
 * Copyright (c) 2014-2015
 * 
 * This file is dual-licensed under the AGPLv3 (http://www.gnu.org/licenses/agpl-3.0.html) 
 * 
 * If you are unsure which license is appropriate for your use, please contact the sales department
 * at 97041437@qq.com.
 */

package cn.com.ksplatform.modules.system.auth.buttonmanager.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.com.ksplatform.base.BaseController;
import cn.com.ksplatform.base.Return;
import cn.com.ksplatform.base.SimpleReturn;
import cn.com.ksplatform.base.page.PageInfoModel;
import cn.com.ksplatform.base.service.BaseService;
import cn.com.ksplatform.modules.system.auth.buttonmanager.model.PlatButtonGroup;
import cn.com.ksplatform.modules.system.auth.buttonmanager.service.PlatButtonGroupService;

/**
 * @ClassName:PlatButtonGroupGroupController <br/>
 * @Date: 2015年5月11日 下午8:40:43 <br/>
 * 
 * @author Mr.Luoxing
 * @version 1.0
 */
@Controller
@RequestMapping("/modules/system/btngroup")
public class PlatButtonGroupController extends BaseController {

	PlatButtonGroupService buttonGroupService;

	@Resource(name = "system.modules.system.PlatButtonGroupService")
	@Override
	public void setBaseService(BaseService baseService) {
		buttonGroupService = (PlatButtonGroupService) baseService;
		super.setBaseService(baseService);
	}

	@RequestMapping("page")
	@ResponseBody
	public PageInfoModel queryPage() throws Exception {
		return super.queryPage(PlatButtonGroup.class);
	}

	@RequestMapping("sou")
	@ResponseBody
	public Return sou(PlatButtonGroup button) throws Exception {
		return SimpleReturn.success("操作成功",buttonGroupService.saveOrUpdate(button));
	}

	@RequestMapping("save")
	@ResponseBody
	public Return save(PlatButtonGroup button) throws Exception {
		return SimpleReturn.success("操作成功",buttonGroupService.save(button));
	}

	@RequestMapping("update")
	@ResponseBody
	public Return update(PlatButtonGroup button) throws Exception {
		return SimpleReturn.success("操作成功",buttonGroupService.update(button));
	}

	@RequestMapping("delete")
	@ResponseBody
	public Return delete(PlatButtonGroup button) throws Exception {
		return SimpleReturn.success("操作成功",buttonGroupService.delete(button));
	}

	@RequestMapping("get/{id}")
	@ResponseBody
	public Return load(@PathVariable String id) {
		return super.load(PlatButtonGroup.class, id);
	}

	@RequestMapping("findAll")
	@ResponseBody
	public Return findAll() throws Exception {
		return super.findAll(PlatButtonGroup.class);
	}
	
	@RequestMapping("getButtons")
	@ResponseBody
	public List getButtons(String btnGId){
		return buttonGroupService.getButtons(btnGId);
	}
}
